<template>

  <div class="icons">
    <swiper :options="IconsSwiperOption">
      <swiper-slide v-for="(page,key) in pages" :key="key">
        <div class="icon" v-for="item in page" :key=item.id>
          <div class="img-icon">
            <img class="img-icon-content" :src=item.imgUrl>
            <p class="keywords">{{item.keywords}}</p>
          </div>
        </div>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>

  </div>

</template>

<script>
  import index from "../../../router";

  export default {
    name: "homeIcons",
    props:{
      iconList:Array
    },
    data() {
      return {
        IconsSwiperOption:{
          pagination: '.swiper-pagination'
        }
      }
    },
    mounted(){

    },
    methods: {

    },
    computed: {
      pages() {
        const pages = [];
        this.iconList.forEach((item, index) => {
          const page = Math.floor(index / 8)
          if (!pages[page]) {
            pages[page] = []
          }
          pages[page].push(item)
        })
        return pages
      }
    }
  }
</script>

<style lang="stylus" scoped>
  @import "~styles/mixins.styl"
  .icons >>> .swiper-container {
    height 0
    overflow hidden
    padding-bottom 55%

    .icon {
      position relative
      float left
      width 25%
      padding-bottom 25%
      overflow hidden

      .img-icon {
        position absolute
        top .2rem
        left 0
        right 0
        bottom .44rem

        .img-icon-content {
          display block
          margin 0 auto
          height 1.1rem
          width 1.1rem
        }

        .keywords {
          padding-top .1rem
          text-align center
          color #212121
          font-size .28rem
          ellopsis()
        }
      }
    }
  }
</style>
